﻿namespace Socut
{
    using System;
    using System.Data;

    public class Data
    {
        private CSql myCSql = new CSql();

        public static DataSet ExecuteDataSet(string SqlscriptOrStoreName, string dataname)
        {
            return ExecuteDataSet(SqlscriptOrStoreName, null, dataname, 0, 0, 0);
        }

        public static DataSet ExecuteDataSet(string SqlscriptOrStoreName, string[,] para, string dataname)
        {
            return ExecuteDataSet(SqlscriptOrStoreName, para, dataname, 0, 0, 0);
        }

        public static DataSet ExecuteDataSet(string SqlscriptOrStoreName, string dataname, int ConnIndex)
        {
            return ExecuteDataSet(SqlscriptOrStoreName, null, dataname, 0, 0, ConnIndex);
        }

        public static DataSet ExecuteDataSet(string SqlscriptOrStoreName, string dataname, int startindex, int num)
        {
            return ExecuteDataSet(SqlscriptOrStoreName, null, dataname, startindex, num, 0);
        }

        public static DataSet ExecuteDataSet(string SqlscriptOrStoreName, string[,] para, string dataname, int ConnIndex)
        {
            return ExecuteDataSet(SqlscriptOrStoreName, para, dataname, 0, 0, ConnIndex);
        }

        public static DataSet ExecuteDataSet(string SqlscriptOrStoreName, string[,] para, string dataname, int startindex, int num)
        {
            return ExecuteDataSet(SqlscriptOrStoreName, para, dataname, startindex, num, 0);
        }

        public static DataSet ExecuteDataSet(string SqlscriptOrStoreName, string dataname, int startindex, int num, int ConnIndex)
        {
            return ExecuteDataSet(SqlscriptOrStoreName, null, dataname, startindex, num, ConnIndex);
        }

        public static DataSet ExecuteDataSet(string SqlscriptOrStoreName, string[,] para, string dataname, int startindex, int num, int ConnIndex)
        {
            if (CLink.Type(ConnIndex) == 1)
            {
                CSql sql = new CSql();
                return sql.ExecuteDataSet(SqlscriptOrStoreName, startindex, num, dataname, para, ConnIndex);
            }
            CAcc acc = new CAcc();
            return acc.ExecuteDataSet(SqlscriptOrStoreName, startindex, num, dataname, para, ConnIndex);
        }

        public static int ExecuteNonQuery(string SqlscriptOrStorename)
        {
            return ExecuteNonQuery(SqlscriptOrStorename, null, 0);
        }

        public static int ExecuteNonQuery(string SqlscriptOrStorename, string[,] para)
        {
            return ExecuteNonQuery(SqlscriptOrStorename, para, 0);
        }

        public static int ExecuteNonQuery(string SqlscriptOrStorename, int ConnIndex)
        {
            return ExecuteNonQuery(SqlscriptOrStorename, null, ConnIndex);
        }

        public static int ExecuteNonQuery(string StoreName, string[,] para, int ConnIndex)
        {
            if (CLink.Type(ConnIndex) == 1)
            {
                CSql sql = new CSql();
                return sql.ExecuteNonQuery(StoreName, para, ConnIndex);
            }
            CAcc acc = new CAcc();
            return acc.ExecuteNonQuery(StoreName, para, ConnIndex);
        }

        public static object ExecuteScalar(string SQL)
        {
            return ExecuteScalar(SQL, null, 0);
        }

        public static object ExecuteScalar(string SQL, string[,] para)
        {
            return ExecuteScalar(SQL, para, 0);
        }

        public static object ExecuteScalar(string SQL, int ConnIndex)
        {
            return ExecuteScalar(SQL, null, ConnIndex);
        }

        public static object ExecuteScalar(string SQL, string[,] para, int ConnIndex)
        {
            if (CLink.Type() == 1)
            {
                CSql sql = new CSql();
                return sql.ExecuteScalar(SQL, para, ConnIndex);
            }
            CAcc acc = new CAcc();
            return acc.ExecuteScalar(SQL, para, ConnIndex);
        }
    }
}

